<?php
/*************************************************

果树金融API - the
Author: Wanghuabin <17-8-18>

*************************************************/
class Hongling{
    private static $CID = '17111500001';
    private static $SKEY = '430e66a9244e36058f8acfcf68e5c5c2';
    private static $SIGN = '2f7205a3f9817bdcc127dc7873bfd200';
    private static $URL = 'http://dev-api.my089.net/thirdUser/8hjrj?';

    public  function get_Platforminfo(){
        $consumerId = self::$CID;
        $time = date('YmdHis',time());
        $sign = self::$SKEY."&consumerId=".$consumerId."&time=".$time."&datakey=Platforminfo";
        $sign = md5($sign);
        $url = self::$URL."consumerId=".$consumerId."&time=".$time."&datakey=Platforminfo&sign=".$sign;
        $content = $this->juhecurl($url,$params,$ispost=1);
        return $content;
    }


    public  function get_Platobject(){
        $consumerId = self::$CID;
        $time = date('YmdHis',time());
        $sign = self::$SKEY."&consumerId=".$consumerId."&time=".$time."&datakey=Subject";
        $sign = md5($sign);
        $url = self::$URL."consumerId=".$consumerId."&time=".$time."&datakey=Subject&sign=".$sign;
        $content = $this->juhecurl($url,$params,$ispost=1);
        return $content;
    }

    public function bind_user($phone,$realname,$idcard,$userid){
            $consumerId = self::$CID;
            $time = date('YmdHis',time());
            $sign = self::$SKEY."&consumerId=".$consumerId."&UserId=".$userid."&phone=".$phone."&time=".$time."&datakey=binduser";
           // echo $sign;die;
            $sign = md5($sign);
            $url = self::$URL."sign=".$sign."&phone=".$phone."&time=".$time."&UserId=".$userid."&datakey=binduser&consumerId=".$consumerId;
             

             $content = $this->juhecurl($url,$params,$ispost=1);
            return $content;
    }



    public function juhecurl($url,$params=false,$ispost=0){
        $httpInfo = array();
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
        curl_setopt( $ch, CURLOPT_USERAGENT , 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22' );
        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 30 );
        curl_setopt( $ch, CURLOPT_TIMEOUT , 30);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
        if( $ispost )
        {
            curl_setopt( $ch , CURLOPT_POST , true );
            curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
            curl_setopt( $ch , CURLOPT_URL , $url );
        }
        else
        {
            if($params){
                curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
            }else{
                curl_setopt( $ch , CURLOPT_URL , $url);
            }
        }
        $response = curl_exec( $ch );
        if ($response === FALSE) {
            return false;
        }
        $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );
        $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );
        curl_close( $ch );
        return $response;
    }


}